package com.jasmine;

import com.jasmine.limit.RateLimiterInterceptor;
import com.jasmine.limit.RateLimiterApi;
import com.jasmine.limit.RateLimiterIp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

import javax.annotation.PostConstruct;

/**
 * @author jasmineXz
 */
@Import(ApiMvcConfig.class)
public class ApiConfig {
    private static final Logger log = LoggerFactory.getLogger(ApiConfig.class);

    @Bean
    public RateLimiterInterceptor apiLimiterInterceptor () {
        return new RateLimiterInterceptor();
    }

    @Bean
    public RateLimiterApi rateLimiterApi () {
        return new RateLimiterApi();
    }

    @Bean
    public RateLimiterIp rateLimiterIp () {
        return new RateLimiterIp();
    }

    @PostConstruct
    public void init() {
        log.info("[BJSTK] [COMMON API MANAGER] ApiConfig Initialization completed");
    }

}
